#include "beremiz.h"
#ifndef __POUS_H
#define __POUS_H

#include "accessor.h"
#include "iec_std_lib.h"

#if 0
__DECLARE_DERIVED_TYPE(AXIS_REF,INT)
__DECLARE_ENUMERATED_TYPE(MC_BUFFER_MODE,
  MC_BUFFER_MODE__MCABORTING,
  MC_BUFFER_MODE__MCBUFFERED,
  MC_BUFFER_MODE__MCBLENDINGLOW,
  MC_BUFFER_MODE__MCBLENDINGPREVIOUS,
  MC_BUFFER_MODE__MCBLENDINGNEXT,
  MC_BUFFER_MODE__MCBLENDINGHIGH
)
__DECLARE_ENUMERATED_TYPE(MC_HOMING_PROCEDURES,
  MC_HOMING_PROCEDURES__MCHOMEDIRECT,
  MC_HOMING_PROCEDURES__MCHOMELIMITSWITCHPOSITIVE,
  MC_HOMING_PROCEDURES__MCHOMELIMITSWITCHNEGATIVE,
  MC_HOMING_PROCEDURES__MCHOMEABSOLUTESWITCHPOSITIVE,
  MC_HOMING_PROCEDURES__MCHOMEABSOLUTESWITCHNEGATIVE,
  MC_HOMING_PROCEDURES__MCHOMEREFERENCEPULSEPOSITIVE,
  MC_HOMING_PROCEDURES__MCHOMEREFERENCEPULSENEGATIVE,
  MC_HOMING_PROCEDURES__MCHOMEABSOLUTE
)
__DECLARE_ENUMERATED_TYPE(MC_DIRECTION,
  MC_DIRECTION__MCABSOLUTEPOSITION,
  MC_DIRECTION__MCPOSITIVEDIRECTION,
  MC_DIRECTION__MCSHORTESTWAY,
  MC_DIRECTION__MCNEGATIVEDIRECTION,
  MC_DIRECTION__MCCURRENTDIRECTION
)
__DECLARE_DERIVED_TYPE(MC_TP_REF,INT)
__DECLARE_DERIVED_TYPE(MC_TV_REF,INT)
__DECLARE_DERIVED_TYPE(MC_TA_REF,INT)
__DECLARE_ENUMERATED_TYPE(MC_EXECUTION_MODE,
  MC_EXECUTION_MODE__MCIMMEDIATELY,
  MC_EXECUTION_MODE__MCQUEUED
)
__DECLARE_ENUMERATED_TYPE(MC_SOURCE,
  MC_SOURCE__MCACTUALVALUE,
  MC_SOURCE__MCSETVALUE
)
__DECLARE_DERIVED_TYPE(MC_CAMSWITCH_REF,INT)
__DECLARE_DERIVED_TYPE(MC_OUTPUT_REF,INT)
__DECLARE_DERIVED_TYPE(MC_TRACK_REF,INT)
__DECLARE_DERIVED_TYPE(MC_TRIGGER_REF,INT)
__DECLARE_DERIVED_TYPE(MC_CAM_REF,INT)
__DECLARE_DERIVED_TYPE(MC_CAM_ID,INT)
__DECLARE_DERIVED_TYPE(MC_START_MODE,INT)
__DECLARE_DERIVED_TYPE(MC_SYNC_MODE,INT)
__DECLARE_ENUMERATED_TYPE(MC_COMBINE_MODE,
  MC_COMBINE_MODE__MCADDAXES,
  MC_COMBINE_MODE__MCSUBAXES
)
__DECLARE_ARRAY_TYPE(__ARRAY_OF_REAL_6,REAL,[6])
typedef __ARRAY_OF_REAL_6 MC_REAL_ARRAY;
__DECLARE_ARRAY_TYPE(__ARRAY_OF_INT_6,INT,[6])
typedef __ARRAY_OF_INT_6 MC_INT_ARRAY;
#endif

__DECLARE_ENUMERATED_TYPE(LOGLEVEL,
  LOGLEVEL__CRITICAL,
  LOGLEVEL__WARNING,
  LOGLEVEL__INFO,
  LOGLEVEL__DEBUG
)
// FUNCTION
BYTE BITS_BYTE(
  BOOL EN, 
  BOOL *__ENO, 
  BOOL BIT0, 
  BOOL BIT1, 
  BOOL BIT2, 
  BOOL BIT3, 
  BOOL BIT4, 
  BOOL BIT5, 
  BOOL BIT6, 
  BOOL BIT7);
// FUNCTION
WORD BITS_WORD(
  BOOL EN, 
  BOOL *__ENO, 
  BOOL BIT0, 
  BOOL BIT1, 
  BOOL BIT2, 
  BOOL BIT3, 
  BOOL BIT4, 
  BOOL BIT5, 
  BOOL BIT6, 
  BOOL BIT7, 
  BOOL BIT8, 
  BOOL BIT9, 
  BOOL BIT10, 
  BOOL BIT11, 
  BOOL BIT12, 
  BOOL BIT13, 
  BOOL BIT14, 
  BOOL BIT15);
// FUNCTION
UDINT TIMESTAMP(
  BOOL EN, 
  BOOL *__ENO, 
  BOOL USERTC);
// FUNCTION_BLOCK LOGGER// GLOBAL

// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(BOOL,TRIG)
  __DECLARE_VAR(STRING,MSG)
  __DECLARE_VAR(LOGLEVEL,LEVEL)

  // FB private variables - TEMP, private and located variables
  __DECLARE_VAR(BOOL,TRIG0)

} LOGGER;

void LOGGER_init__(LOGGER *data__, BOOL retain);
// Code part
void LOGGER_body__(LOGGER *data__);
// FUNCTION_BLOCK PROC_STATE// GLOBAL

// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(BOOL,ERR_HOME)
  __DECLARE_VAR(WORD,ERR_HOME_ID)
  __DECLARE_VAR(BOOL,ERR_MOVE)
  __DECLARE_VAR(WORD,ERR_MOVE_ID)
  __DECLARE_VAR(BOOL,ERR_MOVE1)
  __DECLARE_VAR(BOOL,ERR_MOVE2)
  __DECLARE_VAR(BOOL,HOME)
  __DECLARE_VAR(BOOL,ACT_MOVE)
  __DECLARE_VAR(BOOL,ACT_MOVE0)
  __DECLARE_VAR(INT,OUT)

  // FB private variables - TEMP, private and located variables

} PROC_STATE;

void PROC_STATE_init__(PROC_STATE *data__, BOOL retain);
// Code part
void PROC_STATE_body__(PROC_STATE *data__);
// FUNCTION_BLOCK STEPPER// GLOBAL

// Data part
typedef struct {
  // FB Interface - IN, OUT, IN_OUT variables
  __DECLARE_VAR(BOOL,EN)
  __DECLARE_VAR(BOOL,ENO)
  __DECLARE_VAR(AXIS_REF,AXIS)
  __DECLARE_VAR(REAL,POS)
  __DECLARE_VAR(INT,STATE)
  __DECLARE_VAR(REAL,TARGET)
  __DECLARE_VAR(BOOL,RUN)
  __DECLARE_VAR(BOOL,RUNING)
  __DECLARE_VAR(REAL,SPEED)
  __DECLARE_VAR(REAL,ASPEED)
  __DECLARE_VAR(BOOL,HOME)
  __DECLARE_VAR(REAL,HOMESPEED)
  __DECLARE_VAR(REAL,HOMELOOKUP)
  __DECLARE_VAR(REAL,XIFEN)
  __DECLARE_VAR(MC_DIRECTION,RUN_DIR)
  __DECLARE_VAR(MC_HOMING_PROCEDURES,HOMEMODE)

  // FB private variables - TEMP, private and located variables
  __DECLARE_VAR(MC_BUFFER_MODE,BUFFMODE)
  __DECLARE_VAR(MC_EXECUTION_MODE,MC_SETPOSMODE)
  MC_WRITEPARAMETER MC_WRITEPARAMETER8;
  MC_HOME MC_HOME1;
  MC_MOVEABSOLUTE MC_MOVEABSOLUTE3;
  MC_POWER MC_POWER3;
  MC_READACTUALPOSITION MC_READACTUALPOSITION3;
  PROC_STATE PROC_STATE3;
  MC_SETPOSITION MC_SETPOSITION3;
  MC_WRITEPARAMETER MC_WRITEPARAMETER0;
  MC_WRITEPARAMETER MC_WRITEPARAMETER6;
  R_TRIG R_TRIG0;
  __DECLARE_VAR(BOOL,_TMP_MOVE138_ENO)
  __DECLARE_VAR(BOOL,_TMP_MOVE138_OUT)
  __DECLARE_VAR(BOOL,_TMP_OR222_OUT)
  __DECLARE_VAR(REAL,_TMP_DIV167_OUT)

} STEPPER;

void STEPPER_init__(STEPPER *data__, BOOL retain);
// Code part
void STEPPER_body__(STEPPER *data__);
// PROGRAM PROGRAM0// Global Function


// Data part
typedef struct {
  // PROGRAM Interface - IN, OUT, IN_OUT variables

  // PROGRAM private variables - TEMP, private and located variables
  __DECLARE_VAR(REAL,M1_SPEED)
  __DECLARE_VAR(REAL,M1_POS)
  __DECLARE_VAR(REAL,M1_POS_SET)
  __DECLARE_VAR(REAL,M1_ASPEED)
  __DECLARE_VAR(BOOL,M1_RUN)
  __DECLARE_VAR(INT,M1_STATUS)
  __DECLARE_VAR(BOOL,HOME1)
  __DECLARE_VAR(BOOL,HOME2)
  __DECLARE_VAR(BOOL,HOME3)
  __DECLARE_VAR(BOOL,HOME6)
  __DECLARE_VAR(BOOL,HOME7)
  __DECLARE_VAR(REAL,HOME_SPEED1)
  __DECLARE_VAR(REAL,HOME_SPEED2)
  __DECLARE_VAR(REAL,HOME_SPEED3)
  __DECLARE_VAR(REAL,HOME_SPEED6)
  __DECLARE_VAR(REAL,HOME_SPEED7)
  __DECLARE_VAR(REAL,HOME_SPEED_BACK1)
  __DECLARE_VAR(REAL,HOME_SPEED_BACK2)
  __DECLARE_VAR(REAL,HOME_SPEED_BACK3)
  __DECLARE_VAR(REAL,HOME_SPEED_BACK6)
  __DECLARE_VAR(REAL,HOME_SPEED_BACK7)
  __DECLARE_VAR(REAL,XIFEN1)
  __DECLARE_VAR(REAL,XIFEN2)
  __DECLARE_VAR(REAL,XIFEN3)
  __DECLARE_VAR(REAL,XIFEN6)
  __DECLARE_VAR(REAL,XIFEN7)
  __DECLARE_VAR(REAL,M2_SPEED)
  __DECLARE_VAR(REAL,M2_POS)
  __DECLARE_VAR(REAL,M2_POS_SET)
  __DECLARE_VAR(REAL,M2_ASPEED)
  __DECLARE_VAR(INT,M2_STATUS)
  __DECLARE_VAR(BOOL,M2_RUN)
  __DECLARE_VAR(REAL,M3_SPEED)
  __DECLARE_VAR(REAL,M3_POS)
  __DECLARE_VAR(REAL,M3_POS_SET)
  __DECLARE_VAR(REAL,M3_ASPEED)
  __DECLARE_VAR(INT,M3_STATUS)
  __DECLARE_VAR(BOOL,M3_RUN)
  __DECLARE_VAR(REAL,M3_DELAY)
  __DECLARE_VAR(BYTE,M4_FORCE)
  __DECLARE_VAR(BOOL,M4_ACT)
  __DECLARE_VAR(BYTE,M4_POS)
  __DECLARE_VAR(BYTE,M4_SPEED)
  __DECLARE_VAR(BYTE,M4_RUN)
  __DECLARE_VAR(BYTE,M4_MODE)
  __DECLARE_VAR(WORD,M4_STATUS)
  __DECLARE_LOCATED(WORD,M5_SPEED)
  __DECLARE_LOCATED(WORD,M5_POS)
  __DECLARE_LOCATED(WORD,M5_SPEED_SET)
  __DECLARE_LOCATED(WORD,M5_POS_SET)
  __DECLARE_LOCATED(WORD,M5_STATUS)
  __DECLARE_VAR(REAL,M6_SPEED)
  __DECLARE_VAR(REAL,M6_POS)
  __DECLARE_VAR(REAL,M6_POS_SET)
  __DECLARE_VAR(REAL,M6_ASPEED)
  __DECLARE_VAR(INT,M6_STATUS)
  __DECLARE_VAR(BOOL,M6_RUN)
  __DECLARE_VAR(REAL,M7_SPEED)
  __DECLARE_VAR(REAL,M7_POS)
  __DECLARE_VAR(REAL,M7_POS_SET)
  __DECLARE_VAR(REAL,M7_ASPEED)
  __DECLARE_VAR(INT,M7_STATUS)
  __DECLARE_VAR(BOOL,M7_RUN)
  __DECLARE_VAR(BYTE,M8_POS)
  __DECLARE_VAR(BYTE,M8_SPEED)
  __DECLARE_VAR(BYTE,M8_FORCE)
  __DECLARE_VAR(BOOL,M8_ACT)
  __DECLARE_VAR(BYTE,M8_MODE)
  __DECLARE_VAR(BYTE,M8_RUN)
  __DECLARE_VAR(WORD,M8_STATUS)
  __DECLARE_VAR(BOOL,M9_ACT)
  __DECLARE_VAR(BYTE,M9_SPEED)
  __DECLARE_VAR(BYTE,M9_FORCE)
  __DECLARE_VAR(BYTE,M9_RUN)
  __DECLARE_VAR(INT,M9_POS)
  __DECLARE_VAR(WORD,M9_STATUS)
  __DECLARE_VAR(BOOL,LIANDONG)
  __DECLARE_VAR(REAL,LIANDONG_POS)
  __DECLARE_VAR(REAL,M9_SCALE)
  __DECLARE_VAR(REAL,M7_DELAY)
  __DECLARE_LOCATED(BOOL,X1)
  __DECLARE_LOCATED(BOOL,X2)
  __DECLARE_LOCATED(BOOL,X3)
  __DECLARE_LOCATED(BOOL,X4)
  __DECLARE_LOCATED(BOOL,X5)
  __DECLARE_LOCATED(BOOL,X6)
  __DECLARE_LOCATED(WORD,MB3_HR_1000)
  __DECLARE_LOCATED(WORD,MB3_HR_1001)
  __DECLARE_LOCATED(WORD,MB3_HR_1002)
  __DECLARE_LOCATED(WORD,MB3_HR_1003)
  __DECLARE_LOCATED(WORD,MB3_HR_2000)
  __DECLARE_LOCATED(WORD,MB_HR_2000)
  __DECLARE_LOCATED(WORD,MB_HR_2001)
  __DECLARE_LOCATED(WORD,MB_HR_2002)
  __DECLARE_LOCATED(WORD,MB_HR_2003)
  __DECLARE_LOCATED(WORD,MB_HR_2004)
  __DECLARE_LOCATED(WORD,MB_HR_2005)
  __DECLARE_LOCATED(WORD,MB_HR_2006)
  __DECLARE_LOCATED(WORD,MB_HR_2007)
  __DECLARE_LOCATED(WORD,MB_HR_2008)
  __DECLARE_LOCATED(WORD,MB_HR_1000)
  __DECLARE_LOCATED(WORD,MB_HR_1001)
  __DECLARE_LOCATED(WORD,MB_HR_1002)
  __DECLARE_LOCATED(WORD,MB_HR_1003)
  __DECLARE_LOCATED(WORD,MB_HR_1004)
  __DECLARE_LOCATED(WORD,MB_HR_1005)
  __DECLARE_LOCATED(WORD,MB_HR_1006)
  __DECLARE_LOCATED(WORD,MB_HR_1007)
  __DECLARE_LOCATED(INT,MB_2_1_0_STATUS)
  __DECLARE_LOCATED(UDINT,MB_2_1_0_COUNT)
  __DECLARE_LOCATED(UDINT,MB_2_1_0_COUNT0)
  __DECLARE_LOCATED(INT,MB_3_0_1_STATUS)
  __DECLARE_LOCATED(UDINT,MB_3_0_1_COUNT)
  __DECLARE_LOCATED(UDINT,MB_3_0_1_COUNT0)
  __DECLARE_LOCATED(INT,MB_4_0_0_STATUS)
  __DECLARE_LOCATED(UDINT,MB_4_0_0_COUNT)
  __DECLARE_LOCATED(UDINT,MB_4_0_0_COUNT0)
  STEPPER STEPPER0;
  __DECLARE_VAR(AXIS_REF,AXIS1)
  __DECLARE_VAR(AXIS_REF,AXIS2)
  __DECLARE_VAR(AXIS_REF,AXIS3)
  __DECLARE_VAR(AXIS_REF,AXIS4)
  __DECLARE_VAR(AXIS_REF,AXIS5)
  __DECLARE_VAR(AXIS_REF,AXIS6)
  STEPPER STEPPER1;
  STEPPER STEPPER2;
  STEPPER STEPPER3;
  STEPPER STEPPER4;
  __DECLARE_LOCATED(BOOL,Y1)
  __DECLARE_LOCATED(BOOL,Y2)
  __DECLARE_VAR(MC_HOMING_PROCEDURES,HOME_P)
  __DECLARE_VAR(MC_HOMING_PROCEDURES,HOME_N)
  __DECLARE_VAR(MC_DIRECTION,DIRC_P)
  __DECLARE_VAR(MC_DIRECTION,DIRC_N)
  TON TON0;
  TON TON1;
  R_TRIG R_TRIG0;
  RS RS0;
  TON TON2;
  F_TRIG F_TRIG0;
  R_TRIG R_TRIG1;
  R_TRIG R_TRIG2;
  __DECLARE_VAR(BOOL,TON1_Q)
  __DECLARE_VAR(BOOL,TON2_Q)
  __DECLARE_VAR(BOOL,_TMP_ADD165_ENO)
  __DECLARE_VAR(INT,_TMP_ADD165_OUT)
  __DECLARE_VAR(BOOL,_TMP_ADD126_ENO)
  __DECLARE_VAR(REAL,_TMP_ADD126_OUT)
  __DECLARE_VAR(BOOL,_TMP_MOVE128_ENO)
  __DECLARE_VAR(BYTE,_TMP_MOVE128_OUT)
  __DECLARE_VAR(BOOL,_TMP_MOVE168_ENO)
  __DECLARE_VAR(BOOL,_TMP_MOVE168_OUT)
  __DECLARE_VAR(WORD,_TMP_BYTE_2_WORD43_OUT)
  __DECLARE_VAR(WORD,_TMP_BYTE_2_WORD47_OUT)
  __DECLARE_VAR(WORD,_TMP_BYTE_2_WORD67_OUT)
  __DECLARE_VAR(WORD,_TMP_BYTE_2_WORD15_OUT)
  __DECLARE_VAR(WORD,_TMP_BYTE_2_WORD19_OUT)
  __DECLARE_VAR(WORD,_TMP_BYTE_2_WORD25_OUT)
  __DECLARE_VAR(WORD,_TMP_BITS_WORD23_OUT)
  __DECLARE_VAR(WORD,_TMP_BYTE_2_WORD29_OUT)
  __DECLARE_VAR(WORD,_TMP_INT_TO_WORD58_OUT)
  __DECLARE_VAR(WORD,_TMP_BYTE_2_WORD60_OUT)
  __DECLARE_VAR(BOOL,_TMP_OR172_OUT)
  __DECLARE_VAR(TIME,_TMP_REAL_TO_TIME164_OUT)
  __DECLARE_VAR(BOOL,_TMP_MUL123_ENO)
  __DECLARE_VAR(REAL,_TMP_MUL123_OUT)
  __DECLARE_VAR(BOOL,_TMP_REAL_TO_INT125_ENO)
  __DECLARE_VAR(INT,_TMP_REAL_TO_INT125_OUT)
  __DECLARE_VAR(TIME,_TMP_REAL_TO_TIME161_OUT)
  __DECLARE_VAR(BYTE,_TMP_BITS_BYTE78_OUT)
  __DECLARE_VAR(BOOL,_TMP_BYTE_TO_BOOL77_OUT)
  __DECLARE_VAR(BYTE,_TMP_BITS_BYTE50_OUT)
  __DECLARE_VAR(BOOL,_TMP_BYTE_TO_BOOL49_OUT)
  __DECLARE_VAR(INT,_TMP_MOD56_OUT)
  __DECLARE_VAR(INT,_TMP_DIV63_OUT)
  __DECLARE_VAR(BYTE,_TMP_INT_TO_BYTE65_OUT)

} PROGRAM0;

void PROGRAM0_init__(PROGRAM0 *data__, BOOL retain);
// Code part
void PROGRAM0_body__(PROGRAM0 *data__);
#endif //__POUS_H
void PROGRAM0_Input(PROGRAM0 *data__);
void PROGRAM0_Output(PROGRAM0 *data__);